/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.anorien.dmo;

/**
 *
 * @author David Miguel Antunes <davidmiguel [ at ] antunes.net>
 */
public abstract class Parameter {

    private String name;

    public Parameter(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public abstract int getNSteps();

    public abstract Object getValue(int step);

    @Override
    public String toString() {
        return name;
    }

    public static class DoubleParameter extends Parameter {

        private double min, max;
        int nSteps;

        public DoubleParameter() {
            super("");
        }

        public DoubleParameter(String name, double min, double max, int nSteps) {
            super(name);
            this.min = min;
            this.max = max;
            this.nSteps = nSteps;
        }

        public double getMax() {
            return max;
        }

        public void setMax(double max) {
            this.max = max;
        }

        public double getMin() {
            return min;
        }

        public void setMin(double min) {
            this.min = min;
        }

        public int getNSteps() {
            return nSteps;
        }

        public void setNSteps(int step) {
            this.nSteps = step;
        }

        @Override
        public Object getValue(int step) {
            double val = (getMax() - getMin())
                    * (step / (double) getNSteps())
                    + getMin();
            return val;
        }
    }

    public static class IntegerParameter extends Parameter {

        private int min, max;
        int nSteps;

        public IntegerParameter() {
            super("");
        }

        public IntegerParameter(String name, int min, int max, int nSteps) {
            super(name);
            this.min = min;
            this.max = max;
            this.nSteps = nSteps;
        }

        public int getMax() {
            return max;
        }

        public void setMax(int max) {
            this.max = max;
        }

        public int getMin() {
            return min;
        }

        public void setMin(int min) {
            this.min = min;
        }

        public int getNSteps() {
            return nSteps;
        }

        public void setNSteps(int step) {
            this.nSteps = step;
        }

        @Override
        public Object getValue(int step) {
            double val = (double) (getMax() - getMin())
                    * (step / (double) getNSteps())
                    + getMin();
            return (int) val;
        }
    }

    public static class BooleanParameter extends Parameter {

        public BooleanParameter(String name) {
            super(name);
        }

        public BooleanParameter() {
            super("");
        }

        @Override
        public Object getValue(int step) {
            return step == 0 ? false : true;
        }

        @Override
        public int getNSteps() {
            return 2;
        }
    }
}
